home *** CD-ROM | disk | FTP | other *** search
- APPENDIX C − QUERY-BY-EXAMPLE
- =============================
- In all versions of Powerbase prior to v. 6.99 producing reports (lists) of
- selected records requires you to enter a search formula. (See Ch.3 for full
- details). We will call this the SF method. In v. 6.99 it is possible, for
- the first time, to use an alternative query method called query-by-example
- (QBE for short).
-
- What is QBE?
- ============
- The user is presented with a blank record and invited to type into the
- relevant fields the data which must be matched in order for the record to be
- included in the report (list). What you are saying, in effect, is “I want a
- list of all records which look like this. I don’t care what’s in any of the
- fields I haven’t filled in, but the ones I have filled in must correspond to
- what I have typed.” e.g. in the !Elements database if you wanted to print a
- list of all transition metals you would simply enter T in the Group field
- and then proceed with the list. The tag of the field isn't needed at all,
- whereas using a search formula requires you to type GP=T.
-
- How to use QBE
- ==============
- Choose Print or Print=>Match from the menu (or type the Print key on the
- keyboard). The Match window is displayed and, if you have used an earlier
- version of Powerbase, you will see that its layout has been changed
- somewhat. One of the option switches at the left-hand side is labelled
- Query by example. Click on this with SELECT and the record window will
- display a blank record with the message “Query-by-example”: Enter required
- values in relevant fields in the window title. Enter the data to be matched
- then either click with SELECT on the Print button of the Match window or
- else press the Print key again.
-
- If you simply enter the required target strings Powerbase assumes that you
- want the relevant fields to match exactly, i.e the effect is the same as
- using “=” in a search formula. There are, however, other comparators
- besides “=” which may be used in search formulae. (see 3.3.3, pp.13-14 for
- explanation and complete list). You may use any of these in a QBE query by
- placing them at the start of the string, e.g. {Avenue in an Address field
- would match all records where the field contained the word “Avenue”. An
- address such as “15 Acacia Avenue” could be found by this method whereas
- just entering the word “Avenue” wouldn’t work because it would require the
- field to read “Avenue” and nothing more.
-
- Wildcards may be used; e.g. you could print from the !Elements database all
- elements ending in IUM by entering $IUM in the NAME field or all those whose
- symbol began with H by entering H# in the SYM field.
-
- You may also specify a target list (as described on p. 14) to make the
- search include all records matching any item in the list. e.g.
- Leeds,Liverpool,Manchester in a Town field would cause records with any of
- these places to be included.
-
- On p.13 there is also a description of tag lists which let you instruct
- Powerbase to include records in which only one of a number of fields need
- match the target string. You can do this with QBE provided that the fields
- form a contiguous group. The target string (which may be a target list, be
- wild-carded or be preceded by a comparator) is entered in the first field of
- the group. Press Return and enter " (double quote or "ditto" mark) in the
- next field and for the remaining fields of the group. (Pressing Return
- rather than moving the caret by means of the mouse ensures that you really
- are dealing with a contiguous group of fields.)
-
- QBE vs SF
- =========
- So what are the advantages and disadvantages? QBE is very intuitive and
- avoids the need to bother with field tags or the minutiae of search formula
- syntax. On the other hand SF is more flexible and comprehensive: there are
- some things you simply cannot do with QBE. Some of the limitations have
- already been mentioned but here is a complete list.
-
- • Except where exact matches (“field=target string”) are required it might
- not be possible to fit the target string or list into the relevant
- field. One consequence is that you can't target a Date field for
- all dates prior to, say, 01-06-90 since dates fit their fields
- exactly leaving no room for the necessary < comparator. Such a
- search is perfectly possible with SF.
-
- • Searches involving multiple fields and the same target, i.e. those where
- FieldX or FieldY or FieldZ must match are only possible where the
- fields form a contiguous sequence. With SF it is possible to perform
- such searches on fields dotted about the record.
-
- • There is no equivalent in QBE to the @= (any field in the record matches)
- or @{ (any field contains) searches which are possible with SF
-
- • You can't search for text in an external text field, i.e. fields of Text
- or Text block type. You can with SF.
-
- • You can't include Check-box fields in QBE searches.
-
- • Since QBE doesn't use tags you can’t force a comparison-by-numeric-value
- on a non-numeric field (See 3.3.3, p. 15).
-
- • Calculated fields and those belonging to the Stamp class cannot be used by
- QBE because you cannot type into them!
-
- If your requirements involve only fairly simple searches then QBE might be
- just what you’ve been looking for, but if complex multiple searches are
- often needed then SF is the one to go for. It is, of course, a simple matter
- to switch between the two.
-
- As supplied, Powerbase uses SF as the query method and the Query by example
- switch will be deselected when the Match window is displayed. If you want to
- make QBE the default you can edit the last line of the Config file so that
- the beginning reads QBE instead of SF. Selecting the Print function will
- then produce the blank record without displaying the Match window at all.
- There is, of course, no Print button to click with the mouse after you have
- entered the target strings so you tell Powerbase proceed by pressing the
- Print key again.